<template>
  <div style="margin: 20px 50px;width: 400px">
    <el-form label-width="80px">
      <el-form-item label="信息描述">
        <el-button size="medium" type="info" plain>excel模板说明</el-button>
        <el-link type="primary" href="dev-api/avatar/模板.xls" :underline="false">
          <el-button size="medium" type="primary" plain>点击下载模板</el-button>
        </el-link>
      </el-form-item>
      <el-form-item label="选择Excel">
        <el-upload
          class="upload-demo"
          ref="upload"
          action="dev-api/subject/excel"
          :headers="headers"
          :on-success="handleSuccess"
          :on-error="handleError"
          :auto-upload="false"
        >
          <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
          <el-button style="margin-left: 10px;" size="small" type="success" @click="submitUpload">上传到服务器
          </el-button>
        </el-upload>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import {getToken} from '@/utils/auth'

export default {
  data() {
    return {
      headers: {
        token: getToken()
      }
    }
  },
  created() {

  },
  methods: {
    submitUpload() {
      this.$refs.upload.submit()
    },
    handleSuccess() {
      this.$message.success('上传成功')
    },
    handleError() {
      this.$message.error('上传失败')
    }
  }
}
</script>

<style>

</style>
